#! /bin/sh
#cd ${PROJECT_PATH%/*}
#PROJECT_NAME=${PROJECT_PATH##*/}

BACKUP_HOME=../backup/${PWD##*/}

start(){
 now=`date "+%Y%m%d%H%M%S"`
 mkdir -p $BACKUP_HOME/$now
 cp -r `ls -A | grep -v "logs"` $BACKUP_HOME/$now
 CURRENT_PATH=`pwd`
 cd $BACKUP_HOME;rm -r `ls -t | awk 'NR>7'`
 cd $CURRENT_PATH
 echo "backup=$CURRENT_PATH/$BACKUP_HOME/$now"
}

stop(){
 now=`date "+%Y%m%d%H%M%S"`
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
printf 'Usage: %s {start|stop|restart}\n' "$prog"
exit 1
;;
esac


